<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>申请提现</title>
	<meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" name="viewport"/>
	<meta content="yes" name="apple-mobile-web-app-capable"/>
	<meta content="black" name="apple-mobile-web-app-status-bar-style"/>
	<meta content="telephone=no" name="format-detection"/>
	<link type="text/css" rel="stylesheet" href="/carworld_weixin/themes/css/base.css">
	<link type="text/css" rel="stylesheet" href="/carworld_weixin/themes/css/home.css">
	<link type="text/css" rel="stylesheet" href="/carworld_weixin/themes/css/icon.css">
	<!--<link type="text/css" rel="stylesheet" href="/carworld_weixin/bootstrap/css/bootstrap.css">-->

	<link href="iTunesArtwork@2x.png" sizes="114x114" rel="apple-touch-icon-precomposed">
</head>
<body>
	<header class="aui-navBar aui-navBar-fixed b-line">
		<a href="javascript:history.go(-1);" class="aui-navBar-item">
			<i class="icon icon-return"></i>
		</a>
		<div class="aui-center">

			<span class="aui-center-title">申请提现</span>
		</div>
		<a href="javascript:;" class="aui-navBar-item">
			<i class="icon icon-sys"></i>
		</a>
	</header>
		<div class="aui-cash-list aui-card-list">
			<form id="takeCashForm" name="takeCashForm" action=""  method="post">
			<div class="aui-flex ">
				<div class="aui-text-card">
					<h2>已提现金额：</h2>
				</div>
				<div class="aui-flex-box">
					<h3 id="tCashCount">0</h3>
				</div>
			</div>
			<div class="aui-flex ">
				<div class="aui-text-card">
					<h2>当前可提现金额：</h2>
				</div>
				<div class="aui-flex-box">
					<h3 id="userBalance">0</h3>
				</div>
			</div>
			<div class="aui-flex ">
				<div class="aui-text-card">
					<h2>本次提现金额：</h2>
				</div>
				<div class="aui-flex-box">
					<p class="aui-code-line">
						<input type="text" id="withdrawMoney" name="withdrawMoney" class="aui-code-line-input"  value="" placeholder="请输入提现金额">
					</p>
				</div>
			</div>
			<div class="aui-flex ">
				<div class="aui-text-card">
					<h2>姓名</h2>
				</div>
				<div class="aui-flex-box">
					<p class="aui-code-line">
						<input type="text" class="aui-code-line-input" id="takeName" name="takeName" value="" placeholder="请输入真实姓名">
					</p>
				</div>
			</div>
			<div class="aui-flex ">
				<div class="aui-text-card">
					<h2>预留手机号</h2>
				</div>
				<div class="aui-flex-box">
					<p class="aui-code-line">
						<input id="mobile" type="text" name="mobile" class="aui-code-line-input"  value="" placeholder="请输入手机号">
					</p>
				</div>
			</div>
			
			<div class="aui-flex ">
				<div class="aui-text-card">
					<h2>提现方式</h2>
				</div>
				<div class="aui-flex-box">
					<p class="aui-code-line">
						<label class="cell-right cell-arrow">
							<select id="takeType" name="takeType" class="cell-select">
								<option value="">请选择方式</option>
								<option value="0">支付宝</option>
								<option value="1">银行卡</option>
							</select>
						</label>
					</p>
				</div>
			</div>
			<div class="aui-flex ">
				<div class="aui-text-card">
					<h2>提现账号</h2>
				</div>
				<div class="aui-flex-box">
					<p class="aui-code-line">
						<input id="taccount" type="text" name="taccount" class="aui-code-line-input"  value="" placeholder="请输入提现账号">
					</p>
				</div>
			</div>
				<div id="inputBank">

				</div>

			<div class="aui-code-btn">
				<button id="takeCash" class="btn btn-primary"  onclick="apply()" type="button">确认提现</button>
			</div>
			<div class="aui-Tips">
				<p>温馨提示：</p>
				<p>提现信息务必填写正确,防止提现失败</p>
				<!--<p>当前提现会扣除0.6%的手续费</p>-->
				<p>提现审核通过后，第二天到账</p>
			</div>
			</form>
		</div>



</body>
<script type="text/javascript" src="/carworld_weixin/themes/js/jquery.min.js"></script>
<!--<script type="text/javascript" src="/carworld_weixin/themes/js/slider.js"></script>-->
<!--<script type="text/javascript" src="/carworld_weixin/themes/js/layer.js"></script>-->
<script type="text/javascript">
	$(document).ready(function() {
		init();
	});
	function init(){
        $.ajax({
            url: "../withdraw/getUserBalance",//获取余额
            success:function (data) {
                // console.log(data);
                if(data.userBalance!=null && data.userBalance!=""){
                    $('#userBalance').text(data.userBalance);
				}
                $('#tCashCount').text(data.tCashCount);
            }
        });
	}
	function apply() {
	    var withdrawMoney=$("#withdrawMoney").val();
	    var mobile=$("#mobile").val();
        var taccount=$("#taccount").val();
        var takeType=$("#takeType").val();
        var balance=$('#userBalance').text();
        var takeName=$('#takeName').val();

        if(withdrawMoney==null || withdrawMoney=='' || mobile==null || mobile=='' ||taccount==null || taccount=='' ||takeType==null || takeType=='' ||takeName==null || takeName==''  ){
			alert("信息填写不全");
			return false;
		}


		if(withdrawMoney-balance>0){
            alert('余额不足，提现失败~');
            return false;
		}
        if(takeType=="1"){
            if($("#bankName").val()=="" || $("#bankName").val()==null || $("#bankAddress").val()=="" || $("#bankAddress").val()==null || $("#bankOwnerName").val()=="" || $("#bankOwnerName").val()==null  ){
                alert("信息填写不全");
			} else {
                $('#takeCash').attr('disabled','disabled');
                $.ajax({
                    url: "/carworld_weixin/withdraw/takeCashToAd",
                    type : 'POST',
                    data:{"mobile":mobile,
						"withdrawMoney":withdrawMoney,
						"taccount":taccount,
						"takeType":takeType,
						"takeName":takeName,
                        "bankName":$("#bankName").val(),
						"bankAddress": $("#bankAddress").val(),
						"bankOwnerName": $("#bankOwnerName").val()
						},
                    success:function (data) {
                        console.log(data);
						if("y"==data.result){
                            window.location.href='/carworld_weixin/withdraw/returnWithdrawTakeCashResult';
						}else {
                            alert(data.result);
                            window.location.href='/carworld_weixin/withdraw/takeCashPage';
                        }
                    }
                });

            }
        } else {
            $('#takeCash').attr('disabled','disabled');
            //表单提交takeCashToAd
            $.ajax({
                url: "/carworld_weixin/withdraw/takeCashToAd",
                type : 'POST',
                data:{"mobile":mobile,
                    "withdrawMoney":withdrawMoney,
                    "taccount":taccount,
                    "takeType":takeType,
                    "takeName":takeName
                },
                success:function (data) {
                    console.log(data);
                    if("y"==data.result){
                        window.location.href='/carworld_weixin/withdraw/returnWithdrawTakeCashResult';
                    }else {
                        alert(data.result);
                        window.location.href='/carworld_weixin/withdraw/takeCashPage';
                    }
                }
            });
		}
    }
    //button标签去除按钮默认submit事件
    $('#takeCash').click(function(e){
        e.preventDefult;
        // e.preventDefult();
    });
    $('#takeType').change(function(){
       if($('#takeType').val()=="1"){
			$("#inputBank").append('<div class="aui-flex "><div class="aui-text-card"><h2>开户行</h2></div><div class="aui-flex-box"><p class="aui-code-line"><input type="text" class="aui-code-line-input" id="bankName" name="bankName" value="" placeholder="开户行银行名称"></p></div></div><div class="aui-flex "><div class="aui-text-card"><h2>开户行地址</h2></div><div class="aui-flex-box"><p class="aui-code-line"><input type="text" class="aui-code-line-input" id="bankAddress" name="bankAddress" value="" placeholder="开户省市地址"></p></div></div><div class="aui-flex "><div class="aui-text-card"><h2>银行详细名称</h2></div><div class="aui-flex-box"><p class="aui-code-line"><input type="text" class="aui-code-line-input" id="bankOwnerName" name="bankOwnerName" value="" placeholder="开户行银行详细名称"></p></div></div>');
	   }else{
           $("#inputBank").empty();
	   }
    });


</script>
</html>
